package DataStructures;
import java.util.Arrays;
import java.io.*;
/**
 * Created by msingh on 2014-06-27.
 */
public class BubbleSort {

    public void sort(int[] num){
        for (int i=0; i<num.length;i++)
            for (int x = 1; x < num.length - i; x++) {
                if (num[x - 1] > num[x]) {
                    int temp = num[x];
                    num[x] = num[x - 1];
                    num[x - 1] = temp;
                }
            }
    }
    public static void main(String[] args){
        BubbleSort ob = new BubbleSort();
        int[] num = {22,21,45,67,72,126,4,3,2,1};
        ob.sort(num);
        System.out.println(Arrays.toString(num));

    }
}

